﻿#region Opis pliku
//-----------------------------------------------------------------------------
// TankShotEmitter.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion

#region Using..

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace pogra
{
    /// <summary>
    /// emiter strzału z lufy czołgu
    /// </summary>
    class TankShotEmitter2 :Emitter
    {
        private float tankrotation;

        public TankShotEmitter2(Vector2 Position, Texture2D particleBase, float rotation) :
            base(Position, particleBase)
        {
            tankrotation = rotation;
            life = TimeSpan.FromMilliseconds(20);
        }


        protected override void GenerateParticles()
        {
            maxParticles = 100;
            // generacja nowych cząsteczek
            while (particleList.Count < maxParticles && life > TimeSpan.Zero)
            {
                double lifeSeconds = random.NextDouble() * 0.5 + 0.0001;
                double velocity = random.NextDouble() * 40;
                double rotation = random.NextDouble() * Math.PI*2 + (double)tankrotation;
                particleList.AddLast(new TankShotParticle(particleBase, Position, (float)velocity, (float)rotation, TimeSpan.FromSeconds(lifeSeconds)));

                lifeSeconds = random.NextDouble() * 0.1;
                velocity = random.NextDouble() * 500;
                rotation = random.NextDouble() * 0.1 - 0.05 + (double)tankrotation;
                particleList.AddLast(new TankShotParticle(particleBase, Position, (float)velocity, (float)rotation, TimeSpan.FromSeconds(lifeSeconds)));
            }
        }


    }
}
